{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy\n",
    "import scipy.special"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class NeuralNewwork:\n",
    "    def __init__(self,inputnodes=3,hiddennodes=3,outputnodes=3,learningrate=.3):\n",
    "        self.inodes=inputnodes\n",
    "        self.hnodes=hiddennodes\n",
    "        self.onodes=outputnodes\n",
    "        self.lr=learningrate\n",
    "        self.activation_func=scipy.special.expit\n",
    "\n",
    "        self.wih=numpy.random.normal(0,pow(self.hnodes,-.5),(self.hnodes,self.inodes))\n",
    "        self.who=numpy.random.normal(0,pow(self.hnodes,-.5),(self.onodes,self.hnodes))\n",
    "    \n",
    "    def train(self,inputs_list,targets_list):\n",
    "        # inputs=numpy.array(inputs_list,ndmin=2).T\n",
    "        targets=numpy.array(targets_list,ndmin=2).T\n",
    "        \n",
    "        outputs=self.query(inputs_list)\n",
    "        output_errors=targets-outputs\n",
    "        hidden_errors=numpy.dot(self.who,output_errors)\n",
    "        \n",
    "\n",
    "\n",
    "    def query(self,inputs_list):\n",
    "        inputs=numpy.array(inputs_list,ndmin=2).T\n",
    "        hidden_inputs=numpy.dot(self.wih,inputs)\n",
    "        hidden_outputs=self.activation_func(hidden_inputs)\n",
    "        final_inputs=numpy.dot(self.who,hidden_outputs)\n",
    "        final_outputs=self.activation_func(final_inputs)\n",
    "        return final_outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.53630659],\n",
       "       [0.53007987],\n",
       "       [0.42363518]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nn=NeuralNewwork()\n",
    "nn.query(numpy.random.random(3)-.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "eca205237a0276efc01863ad331f2d247e6b71c5c99a7311dd990da7d5151376"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
